#ifndef AMARANTHUSCOMMON_H
#define AMARANTHUSCOMMON_H

#include "itkImage.h"
#include "itkImageBase.h"
#include "itkSmartPointer.h"
#include "itkRGBAPixel.h"
#include "itkLabelObject.h"
#include "itkLabelMap.h"

#include "vtkImageData.h"
#include "vtkSmartPointer.h"
#include "vtkActor.h"
#include "vtkPolyData.h"

#include <QVector>
#include <QColor>

class Material;

typedef itk::ImageBase<3> ImageBaseType;
typedef typename ImageBaseType::Pointer ImageBasePointer;

typedef itk::Image<float,3> GreyImageType;
typedef GreyImageType::Pointer GreyImagePointer;

typedef itk::Image<unsigned long,3> BinaryImageType;
typedef BinaryImageType::Pointer BinaryImagePointer;

typedef itk::LabelObject<unsigned long, 3> LabelObjectType;
typedef LabelObjectType::Pointer LabelObjectPointer;
typedef itk::LabelMap<LabelObjectType> LabelMapType;
typedef LabelMapType::Pointer LabelMapPointer;

typedef vtkImageData DisplayImageType;
typedef vtkSmartPointer<DisplayImageType> DisplayImagePointer;

typedef vtkPolyData PolyDataType;
typedef vtkSmartPointer<PolyDataType> PolyDataPointer;

typedef QVector<Material*> Materials;
typedef typename Materials::iterator MaterialsIterator;

class Material
{

public:
    typedef vtkSmartPointer<vtkActor> ActorPointer;

    Material(int label, QString name, unsigned char R, unsigned char G, unsigned char B,
             float density, float lowerThreshold, float upperThreshold) :
        m_Name(name), m_Density(density)
    {
        m_Color.setRgb(R, G, B);
        m_Value[0] = lowerThreshold;
        m_Value[1] = upperThreshold;
        m_Label = label;
        m_Actor = NULL;
    }

    Material() {}
    ~Material() {}

    float* GetValue()
    { return m_Value; }

    unsigned long GetLabel()
    { return m_Label; }

    QString GetName()
    { return m_Name; }

    QColor GetColor()
    { return m_Color; }

    void SetVolume(LabelMapPointer volume)
    { m_Volume = volume;}

    LabelMapPointer GetVolume()
    { return m_Volume; }

   vtkActor* GetActor()
    { return m_Actor; }

    void DeleteActor()
    { m_Actor = NULL; }

    void SetActor(vtkActor* actor)
    { m_Actor = actor; }

private:
    unsigned long m_Label;
    QString m_Name;
    QColor m_Color;
    float m_Value[2];
    float m_Density;
    LabelMapPointer m_Volume;
    vtkActor* m_Actor;
 // element composition
};
#endif
